/*
 * @Author: szx
 * @Date: 2022-03-13 13:25:14
 * @LastEditTime: 2022-03-13 13:28:21
 * @Description:
 * @FilePath: \leetcode\1-99\78\78_2.js
 */
/**
 * @param {number[]} nums
 * @return {number[][]}
 */
var subsets = function (nums) {
    const n = nums.length;
    const res = [];
    const backtrace = (path, index) => {
        if (path.length <= n) {
            res.push(Array.from(path));
        }
        for (let i = index; i < n; i++) {
            path.push(nums[i]);
            backtrace(path, i + 1);
            path.pop();
        }
    };
    backtrace([], 0);
    return res;
};
console.log(subsets([1, 2, 3]));
